package com.hrd.admin.task;

import com.hrd.service.CustomerService;
import com.hrd.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @Author: wangpeng
 * @Date: 2022/1/18 10:05
 * @Description: 付款单同步
 */
@Component
@Slf4j
public class PaybillTask {
    @Autowired
    OrderService orderService;
    private boolean running=true;
    /**
     * 同步客户信息
     */
     @Scheduled(cron="0 30 23 * * ?")
    public void synchronizationOrder() {
        log.info("====PaybillTask:收款单同步定时开始======");
        try {
            if(running){
                running=false;
                orderService.syncCollectionOrder();
                running=true;
            }else{
                log.info("本轮未执行完：PaybillTask");
            }
        } catch (Exception e) {
            running=true;
            e.printStackTrace();
        }
        log.info("====PaybillTask:收款单同步定时结束======");
    }
}
